package cn.bdqn.pn.reposity.user;

import cn.bdqn.pn.pojo.user.Admin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface AdminReposity extends JpaRepository<Admin,Integer>, JpaSpecificationExecutor<Admin> {
    /**
     * 查询账号密码登录登录
     * @param adminAccount
     * @param adminPwd
     * @return
     */
    Admin findAdminByAccountAndAdminPwd(String adminAccount,String adminPwd);
    // 根据账号查询用户
   @Query(value = "SELECT * FROM admin WHERE account=:account", nativeQuery = true)
    Admin findByUsername(@Param("account") String account);


    /**
     * 根据id判断是否有下级
     * @param adminId
     * @return
     */
    @Query(value = "SELECT * FROM admin WHERE fatherId= :adminId", nativeQuery = true)
    Admin findInfoByFatherId(@Param("adminId") Integer adminId);
}
